package info.motteke.qjdbc.column;

import info.motteke.qjdbc.column.filter.EqualFilter;
import info.motteke.qjdbc.column.filter.GreaterFilter;
import info.motteke.qjdbc.column.filter.GreaterOrEqualFilter;
import info.motteke.qjdbc.column.filter.LessFilter;
import info.motteke.qjdbc.column.filter.LessOrEqualFilter;
import info.motteke.qjdbc.column.variable.IntVariable;
import info.motteke.qjdbc.column.variable.Variable;
import java.sql.ResultSet;
import java.sql.SQLException;

public final class ObjectMeta extends Meta {

    public ObjectMeta(String name) {
        super(name);
    }

    public GreaterFilter greaterThan(int value){
        return greaterThan(new IntVariable(value));
    }

    public GreaterFilter greaterThan(Variable var){
        return new GreaterFilter(var);
    }

    public GreaterOrEqualFilter greaterThanOrEqual(Variable var){
        return new GreaterOrEqualFilter(var);
    }

    public EqualFilter equal(Variable var){
        return new EqualFilter(var);
    }

    public LessOrEqualFilter lessThanOrEqual(Variable var){
        return new LessOrEqualFilter(var);
    }

    public LessFilter lessThan(Variable var){
        return new LessFilter(var);
    }

    Object getValue(ResultSet rs) throws SQLException {
        return rs.getObject(getName());
    }
}
